﻿using RpcCentral.DAL;
using RpcCentral.Model.DB;
using RpcModel.Model;
using SqlSugarHelper;

namespace RpcCentral.DAL.Repository
{
    internal class ServerLimitConfigDAL : IServerLimitConfigDAL
    {
        private IRepository<ServerLimitConfigModel> _Db;
        public ServerLimitConfigDAL(IRepository<ServerLimitConfigModel> db)
        {
            _Db = db;
        }
        public ServerLimitConfig GetLimitConfig(long serverId)
        {
            return this._Db.Get(a => a.ServerId == serverId, a => new ServerLimitConfig
            {
                BucketOutNum = a.BucketOutNum,
                BucketSize = a.BucketSize,
                IsEnable = a.IsEnable,
                IsEnableBucket = a.IsEnableBucket,
                LimitNum = a.LimitNum,
                LimitTime = a.LimitTime,
                LimitType = a.LimitType,
                TokenInNum = a.TokenInNum,
                TokenNum = a.TokenNum
            });
        }

    }
}
